package online.flowerinsnow.minecraft.bukkit.testffa.event;

import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/**
 * 当玩家死亡时触发
 */
public class PlayerDiedEvent extends Event implements Cancellable {
    @NotNull public static final HandlerList HANDLER_LIST = new HandlerList();

    public boolean cancelled;

    /**
     * 死亡的玩家
     */
    @NotNull public final Player player;
    /**
     * 击杀者
     */
    @Nullable public final Player killer;

    public PlayerDiedEvent(@NotNull Player player, @Nullable Player killer) {
        this.player = player;
        this.killer = killer;
    }

    @Override
    public boolean isCancelled() {
        return cancelled;
    }

    @Override
    public void setCancelled(boolean b) {
        this.cancelled = b;
    }

    @Override
    public HandlerList getHandlers() {
        return HANDLER_LIST;
    }

    public static HandlerList getHandlerList() {
        return HANDLER_LIST;
    }
}
